package org.terramagnet.workflow.dynamic.databinding.type;

import org.apache.commons.lang3.BooleanUtils;

/**
 *
 * @author terrason
 */
public class BooleanType extends BaseDataType<Boolean> {

    @Override
    public String caption() {
        return "布尔型";
    }

    @Override
    public Boolean parse(String text, Boolean defaultValue) {
        Boolean toBooleanObject = BooleanUtils.toBooleanObject(text);
        return toBooleanObject == null ? defaultValue : toBooleanObject;
    }

    @Override
    public Boolean parse(String text) throws IllegalArgumentException {
        return BooleanUtils.toBooleanObject(text);
    }

    @Override
    public int precision() {
        return 0;
    }

    @Override
    public int length() {
        return 1;
    }

}
